<template>
	<uni-popup ref="popup" type="bottom">
		<view class="multiple-select-layout">
			<view class="multiple-select-item" v-for="(item, index) in mutipleData" @click="itemClick(item)">
				<view class="multiple-select-item-text">{{item.name}}</view>
				<image class="multiple-select-item-img" :src="ftpUrl + ((item.isChecked == true)?'/ic_check_box_select.png':'/ic_check_box_normal.png')"></image>
			</view>
			<view class="bottom-btn-layout">
				<view class="bottom-btn-cancel" @click="cancelClick">取消</view>
				<view class="bottom-btn-confirm" @click="confirmClick">确定</view>
			</view>
		</view>
	</uni-popup>
</template>

<script>
	export default {
		data() {
			return {
				mutipleData: [],
			}
		},
		methods: {
			//显示弹窗
			show(dataList) {
				if(dataList){
					this.mutipleData = dataList
				}
				this.$refs.popup.open()
			},
			
			//item点击
			itemClick(item){
				item.isChecked = !item.isChecked
			},
			
			//点击取消
			cancelClick(){
				this.$refs.popup.close()
			},
			
			//点击确定
			confirmClick(){
				let slectList = this.mutipleData.filter((val) => val.isChecked == true)
				this.$emit('mutipleSeleckBack', slectList)
				this.cancelClick()
			}
		}
	}
</script>

<style scoped>
	.multiple-select-layout{
		width: 100%;
		display: flex;
		flex-direction: column;
		padding: 0 32rpx;
		box-sizing: border-box;
		background-color: white;
	}
	.bottom-btn-layout{
		width: 100%;
		display: flex;
		flex-direction: row;
		align-items: center;
		padding: 20rpx 18rpx;
		box-sizing: border-box;
		margin-top: 32rpx;
	}
	.bottom-btn-cancel,
	.bottom-btn-confirm{
		flex: 1;
		height: 72rpx;
		line-height: 72rpx;
		text-align: center;
		border: 1rpx solid #336DEE;
		font-size: 28rpx;
		border-radius: 44rpx;
	}
	.bottom-btn-cancel{
		background-color: white;
		color: #336DEE;
		margin-right: 16rpx;
	}
	.bottom-btn-confirm{
		background-color: #336DEE;
		color: white;
		margin-left: 16rpx;
	}
	.multiple-select-item{
		width: 100%;
		display: flex;
		flex-direction: row;
		align-items: center;
		padding: 30rpx 0;
		box-sizing: border-box;
		border-bottom: 1rpx solid #F4F7FF;
	}
	.multiple-select-item-text{
		flex: 1;
		font-size: 28rpx;
		color: #2D323B;
	}
	.multiple-select-item-img{
		width: 32rpx;
		height: 32rpx;
	}
</style>
